<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

<head>
    <title>testSomething</title>
    <meta charset="UTF-8">
    <script type="text/javascript" src="./jstest.js"></script>
</head>
<p id="word">计算1+2</p>
    <script>
        //document.write("计算1+2");
        //var cars = new Object();
        //cars.name = "Audi";
        //document.write(cars.name + " is a good car!");
        //console.log(cars.name + " is a good car! this is console");
        function num() {
            let x = document.getElementById("word");
            x.innerHTML="a+b=" + jiafa(1, 2);
        }

        function num1() {
            alert("a+b=" + jiafa(1, 2));
        }

        function num2() {
            document.write("a+b=" + jiafa(1, 2));
        }

        function num3(){
            var entity = { name:"Block", age: 10};
            var user = new duixiang1(entity);
            let x = document.getElementById("word");
            x.innerHTML="他叫"+user.name+"，他"+user.age+"岁了！";
        }

        function num4(){
            try {
                var entity = {name: "Bob", age: 10};
                var user = new duixiang(entity);
                let x = document.getElementById("word");
                x.innerHTML = "他叫" + user.name + "，他" + user.age + "岁了！";
            }catch(err){
                document.getElementById("word").innerHTML = "Error: "+ err + "!";
            }
        }

        function day(){
            document.getElementById("word").innerHTML = myFunction();
        }

        function input(){
            try {
                var input = document.getElementById("demo").value;
                if (input=="") throw "值为空";
                if (isNaN(input)) throw "不是数字";
                if (input < 5) throw "小于5了";
                if (input >10) throw "大于10了";
                if (input<10 && input>5) throw "ok pass";

                 }catch(err){
               document.getElementById("word").innerHTML = "notice: "+err;
            }
        }
    </script>

<br> </br>
    <input id="demo" type="text">输入大于5小于10的数字</input>
    <button type = "button" onclick="input()">验证数字</button><br>
    <button type = "button" onclick="num()">更改已有的文字</button><br>
    <button type = "button" onclick="num1()">弹框方式显示</button><br>
    <button type = "button" onclick="num2()">写入HTML方式显示</button><br>
    <button type = "button" onclick="num3()">访问对象通过class方式</button><br>
    <button type = "button" onclick="num4()">访问对象通过function方式</button><br>
    <button type = "button" onclick="day()">获取今天是星期几</button>
</body>
</html>